<?php
#this shouldnt be rewrited
class Converter 
{
	function convert($num)
	{
		return $this->custombase_convert_big ($num, 10, 62);
	}
	
	function custombase_convert_big ($numstring, $frombase, $tobase)
	{
	   $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	   $tostring = substr($chars, 0, $tobase);
	   $numstring = strtolower($numstring);
	   $length = strlen($numstring);

	   $number = array();
	   for ($i = 0; $i < $length; $i++) {
		  $number[$i] = strpos($chars, $numstring{$i});
	   }

	   $result = '';
	   do {
		  $divide = 0;
		  $newlen = 0;
		  for ($i = 0; $i < $length; $i++) {
			 $divide = $divide * $frombase + $number[$i];
			 if ($divide >= $tobase) {
				$number[$newlen++] = (int) ($divide / $tobase);
				$divide = $divide % $tobase;
			 } elseif ($newlen > 0) {
				$number[$newlen++] = 0;
			 }
		  }
		  $length = $newlen;
		  $result = $tostring{$divide} . $result;
	   } while ($newlen != 0);
	   return $result;
	}
};
?>